/*
	Author: Superxpdude
	
	Description:
	Tells the server to save a certain variable in the .ini Database
	
	Parameters:
	_this select 0: UID of client that needs to load data
	_this select 1: Unit of client that needs to load data
	_this select 2: String with requested data to load
	
	Example:
	array = ["playerUID","player", "score"];
	
	Returns:
	String, Number or Array containing requested data
*/
private ["_playerUID","_player","_load","_data"];

//Clear variables to use later
iniDB_loadRequest = nil;
iniDB_loadResponse = nil;

// Define variables to send to the server
_playerUID = [_this, 0, nil, [0]] call BIS_fnc_param;
_player = [_this, 1, objnull, [objnull]] call BIS_fnc_param;
_load = [_this, 2, "error", [""]] call BIS_fnc_param;

// Check for invalid variables
if (isNil _playerUID) exitwith {["PlayerUID must be defined when calling the load function."] call BIS_fnc_error; false};
if (isNull _player) exitwith {["Player unit must be defined when calling the load function."] call BIS_fnc_error; false};
if ((getPlayerUID _player) != _playerUID) exitwith {["Player unit and PlayerUID do not match."] call BIS_fnc_error; false};
if (_save == "error") exitwith {["Undefined save type."] call BIS_fnc_error; false};

// Send load request to the server
iniDB_loadRequest = [_playerUID, _player, _load];
publicVariableServer "iniDB_loadRequest";

// Wait for response
waitUntil {!isNil "iniDB_loadResponse"};

// Transfer loaded data to a local variable
_data = iniDB_loadResponse;

// Delete unused variables
iniDB_loadRequest = nil;
iniDB_loadResponse = nil;

//Return data to script
_data